package com.pengtu.gsj.dao.check.gcjs;

import java.util.List;




import org.springframework.stereotype.Repository;

import com.pengtu.gsj.dao.hibernate.HibernateDao;
import com.pengtu.gsj.entity.gcjs.XXRoadConstructionA;

/**
 * 
 * 
 * XXRoadConstructionADao
 * 
 * 2017年5月19日 下午3:24:45
 * 
 * @version 1.0.0
 *
 */
@Repository
public class XXRoadConstructionADao extends HibernateDao<XXRoadConstructionA, String> {
	
	public List<XXRoadConstructionA> getCouRoadConYear(String startTime, String endTime) {
		String hql = "select new com.pengtu.gsj.entity.gcjs.XXRoadConstructionA(t.year) from XXRoadConstructionA t where t.delFlag='0' and t.year <="+endTime+"and t.year >="+startTime+" group by t.year order by t.year asc";
		return find(hql);
	}

	public List<XXRoadConstructionA> searchForResult(String startTime, String endTime) {
		String hql = "select new com.pengtu.gsj.entity.gcjs.XXRoadConstructionA(SUM (t.itemNum) AS itemSum,"
					+"Round(SUM(t.itemNum * t.workNum) / SUM (t.itemNum), 2) AS workSum,"
					+"Round(SUM(t.itemNum * t.workNum * t.completeNum) / SUM(t.itemNum * t.workNum), 2) as completeSum,"
					+"Round(SUM(t.itemNum * t.workNum * t.completeNum * t.acceptNum) / SUM(t.itemNum * t.workNum * t.completeNum), 2) as acceptSum) from XXRoadConstructionA t where t.delFlag='0' and t.year >= ? and t.year <= ?";
			return find(hql, startTime, endTime);
	}
}
